package com.hos;

import com.hos.bean.WriteResult;
import com.hos.utils.FileUtils;
import com.hos.utils.PKCS7Parser;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class GetHosFacetIDServlet extends HttpServlet {


    public GetHosFacetIDServlet() {
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        // 保存上传的文件
        WriteResult result = FileUtils.writeToFile(request);
        if (result.isFailed()) {
            response.getWriter().println(result.getMessage());
            return;
        }
        // 拿到development-certificate值，计算FacetID
        response.getWriter().println(PKCS7Parser.getFacetID(result.getMessage()));
    }
}
